# Contributor: Alex Laskin <alex@lask.in>
# Maintainer: Alex Laskin <alex@lask.in>
pkgname=autofs
pkgver=5.1.6
pkgrel=1
pkgdesc="A kernel-based automounter for Linux"
url="https://www.kernel.org/pub/linux/daemons/autofs/"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers automake flex bison rpcgen libtirpc-dev libnfs-dev coreutils"
subpackages="$pkgname-doc $pkgname-openrc"
options="!check" # no test suite provided
source="
	https://www.kernel.org/pub/linux/daemons/$pkgname/v5/$pkgname-$pkgver.tar.xz
	autofs.initd
	autofs.confd
	pid_t.patch
	10-glibc.patch
	"

prepare() {
	default_prepare
	sed -i 's,nfs/nfs.h,linux/nfs.h,g' */*.[ch]
	sed -i 's,__S_IEXEC,S_IXUSR,g' */*.[ch]
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc/autofs \
		--with-mapdir=/etc/autofs \
		--with-confdir=/etc/conf.d \
		--without-hesiod \
		--with-libtirpc \
		--enable-ignore-busy
	make
}

package() {
	make DESTDIR="$pkgdir" install

	mkdir -p "$pkgdir"/etc/autofs/
	install -m644 samples/auto.master \
		samples/auto.misc \
		samples/auto.net \
		samples/auto.smb \
		"$pkgdir"/etc/autofs/

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname

	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname

	rm -f "$pkgdir"/usr/share/man/man5/autofs.5
}

sha512sums="dc8b2bd86c140905dd1bc461bfc469f92363d9c2687fe422e1e751cc7ad64c0733b011c80bf4840e510e5909176cd1a066968b9a5ba835b62c4cf27537863cf2  autofs-5.1.6.tar.xz
e7ffe40cf5f302f7de7cc59752699adad4be89fa78fa1a79c32ce4059ec2f563c0f107ca2cec850cabfb1cdebca5ff1f369167479423ab6cfe509225a799a00e  autofs.initd
74884b94d8c5dc72579c9c0c9f13c8918ee0babe6fc1e6352bb79cfaf6f5ce3daa87a9b2ea2f34a4600c93a971b329aa0892785fe2efd42829fb7953a6130dd7  autofs.confd
78dfd13e06a7adec4336b18a03a1c0bd9d651ce01bf5e716a75d5574e033db9c3fff3baf660c4a6ad757403db5242a7abecf68cdb4cc9bb4d005992b6fe44ca6  pid_t.patch
0de8adc821fa59a9c5392ea5e4a3b540a39f38b8bb2ddde8d20ca4946e3d1467c80bb375d918a11e2331281e220da56e66c2aa1e974b9e6e40c7d3a3b4cdac5e  10-glibc.patch"
